package iddstaskcreate;

import Main.Parameters;
import plugin.SystemInterface;

/**
 *
 * @author ZeM
 */
public class CreateTask implements SystemInterface {

    int old_console_input_receiver; //ID of old console input receiver
    Thread working_thread;
    CreateTaskDo thread_slave;
    public void start() {
        old_console_input_receiver = Parameters.LibConsoleInputReceiver;
        int k = 0;
        boolean found = false;
        while (!found) {
            if (Parameters.RunningLibs[k].equals("iddsTaskCreate")) {
                found = true;
            } else {
                k++;
            }
        }

        Parameters.LibConsoleInputReceiver = k;
        //start thread
        thread_slave=new CreateTaskDo();
        working_thread=new Thread(thread_slave);
        working_thread.start();

    }

    public void interrupt() {
        working_thread.interrupt();
    }

    public void pause() {
        try {
            working_thread.wait();
        } catch (InterruptedException ex) {

        }
    }

    public void play() {
            working_thread.notify();
    }

    public void input(String message) {
            thread_slave.input(message);
    }
}
